package com.zky.gulimall.product;


import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
 * @Description TODO
 * @Author 张开源
 * @Date 2022/11/11 23:06
 * @Version 1.0
 **/
public class LockSupportDemo {
    public static void main(String[] args) {


        Thread t1 = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + "\t---------------come in");
            LockSupport.park();
            System.out.println(Thread.currentThread().getName() + "\t---------------被唤醒");
        }, "t1");
        t1.start();

        try {
            TimeUnit.MILLISECONDS.sleep(20);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        new Thread(() -> {
            LockSupport.unpark(t1);
            System.out.println(Thread.currentThread().getName() + "\t---------------发出通知");
        }, "t2").start();
    }
}
